import { View } from "../../../../mvc/core/View";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { TDramaCopy } from "../../../../../Message/Db/Tables/TDramaCopy";
import { Cache } from "../../../cache/Cache";
import { Language } from "../../../../../extend/language/Language";
import { ItemData } from "../../../resource/info/ItemData";
import { BaseItem } from "../../common/BaseItem";
import { EActiveType } from "../../../../../Message/Public/EActiveType";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Lv70DramaItem } from "../data/Lv70DramaItem";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { HighlightManager } from "../../../manager/HighlightManager";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class Lv70DramaEnterView
    
    export  class Lv70DramaEnterView extends View
    {
        constructor(arg1: ILayer=null)
        {
            super();
            this.layer = arg1;
            this.initView();
            return;
        }

        public updateData(arg1: TDramaCopy, arg2: Function, arg3: Function): void
        {
            var loc12=null;
            var loc13=0;
            if (arg1 == null) 
            {
                return;
            }
            this._data = arg1;
            this._enterCall = arg2;
            this._delegateCall = arg3;
            var loc1=Cache.instance.copy.getLv70HightesHistory(this._data.difficulty);
            var loc2="";
            if (Cache.instance.copy.isLv70DramaTodayDone(this._data.copyCode)) 
            {
                loc2 = "<font color=\'#FE0000\'>(" + Language.getString(80139) + ")</font>";
            }
            this._txtChapter.htmlText = Language.getStringByParam(80132, this._data.titleOne);
            this._txtLayer.htmlText = Language.getStringByParam(80133, this._data.titleTwo) + loc2;
            var loc3=this._data.mainDrop.split("#");
            var loc4=int(loc3[0]);
            var loc5=int(loc3[1]);
            var loc6=int(loc3[2]);
            var loc7=new ItemData(loc4);
            this._mainDrop.itemData = loc7;
            this._mainDrop.amount = 1;
            var loc8=loc5.toString();
            if (loc3.length >= 3) 
            {
                loc8 = loc8 + ("~" + loc6.toString());
            }
            this._txtMainDrop.htmlText = loc7.htmlName + loc8 + Language.getString(80136);
            loc3 = this._data.otherDrop.split("#");
            var loc9=0;
            while (loc9 < 6) 
            {
                (loc12 = this._otherDrops[loc9] as BaseItem).visible = false;
                if (!(loc9 >= loc3.length)) 
                {
                    loc12.visible = true;
                    loc13 = int(loc3[loc9]);
                    loc12.itemData = new ItemData(loc13);
                    loc12.amount = 1;
                }
                ++loc9;
            }
            var loc10=Cache.instance.active.isActiveInEffect(EActiveType._EActiveTypeDramaReward);
            var loc11=Cache.instance.active.isActiveInEffect(EActiveType._EActiveTypeDramaMultiDrop);
            if (loc10) 
            {
                this._activeTip1.htmlText = Language.getString(69719);
            }
            else 
            {
                this._activeTip1.htmlText = "";
            }
            if (loc11) 
            {
                this._activeTip2.htmlText = Language.getString(69719);
            }
            else 
            {
                this._activeTip2.htmlText = "";
            }
            if (loc10 || loc11) 
            {
                this._bg.height = 260;
            }
            else 
            {
                this._bg.height = 240;
            }
            return;
        }

        /* internal  */initView(): void
        {
            var loc5=null;
            this._bg = ObjCreate.createBg(0, 0, 355, 240, this, ImagesConst.ToolTipBg);
            ObjCreate.createBg(20, 84, 315, 1, this, ImagesConst.SplitLine);
            ObjCreate.createBg(20, 141, 315, 1, this, ImagesConst.SplitLine);
            var loc1=ObjCreate.createGTextField("", 0, 8, 355, 20, this);
            var loc2=loc1.defaultTextFormat;
            loc2.size = 16;
            loc2.align = flash.text.TextFormatAlign.CENTER;
            loc2.bold = true;
            loc1.defaultTextFormat = loc2;
            loc1.htmlText = Language.getString(80131);
            this._txtChapter = ObjCreate.createGTextField("", 20, 38, 300, 20, this);
            this._txtLayer = ObjCreate.createGTextField("", 20, 62, 300, 20, this);
            this._txtMainDrop = ObjCreate.createGTextField("", 126, 107, 200, 20, this);
            loc1 = ObjCreate.createGTextField("", 20, 107, 200, 20, this);
            loc1.htmlText = Language.getString(80135);
            loc1 = ObjCreate.createGTextField("", 20, 167, 200, 20, this);
            loc1.htmlText = Language.getString(80137);
            this._mainDrop = new Lv70DramaItem();
            this._mainDrop.x = 83;
            this._mainDrop.y = 96;
            this.addChild(this._mainDrop);
            this._otherDrops = [];
            var loc3=0;
            while (loc3 < 6) 
            {
                (loc5 = new Lv70DramaItem()).x = 83 + loc3 * 42;
                loc5.y = 154;
                this.addChild(loc5);
                this._otherDrops.push(loc5);
                ++loc3;
            }
            var loc4;
            (loc4 = ObjCreate.createGButton("", 315, 10, 27, 28, this, "RedBigXCloseBtn")).addEventListener(flash.events.MouseEvent.CLICK, this.clickCloseHandler);
            this._enterBtn = ObjCreate.createGButton(Language.getString(20029), 35, 203, 75, 25, this, "DialogOptBtn");
            this._delegateBtn = ObjCreate.createGButton(Language.getString(69712), 135, 203, 75, 25, this, "DialogOptBtn");
            this._warehouseBtn = ObjCreate.createGButton(Language.getString(42508), 235, 203, 75, 25, this, "DialogOptBtn");
            this._enterBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._delegateBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._warehouseBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._activeTip1 = ObjCreate.createGTextField("", 20, 233, 105, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle._textFormatGreen));
            this._activeTip1.mouseEnabled = false;
            this._activeTip2 = ObjCreate.createGTextField("", 120, 233, 105, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle._textFormatGreen));
            this._activeTip2.mouseEnabled = false;
            return;
        }

        /* internal  */clickCloseHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            return;
        }

        public highlightWareHouseBtn(arg1: Boolean): void
        {
            HighlightManager.instance.glowEffectButton(this._warehouseBtn, arg1);
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this.highlightWareHouseBtn(false);
            return;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target;
            switch (loc1) 
            {
                case this._enterBtn:
                {
                    if (this._enterCall != null) 
                    {
                        this._enterCall.call(null, this._data, false);
                        this.hide();
                    }
                    break;
                }
                case this._delegateBtn:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.DelegateDramaCopy, this._data));
                    this.hide();
                    break;
                }
                case this._warehouseBtn:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ShowDelegateWareHouse));
                    break;
                }
            }
            return;
        }

        public clean(): void
        {
            this._data = null;
            this._enterCall = null;
            this._delegateCall = null;
            return;
        }

        /* internal */ /* var */_data: TDramaCopy;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_txtChapter: GTextFiled;

        /* internal */ /* var */_txtLayer: GTextFiled;

        /* internal */ /* var */_txtMainDrop: GTextFiled;

        /* internal */ /* var */_mainDrop: Lv70DramaItem;

        /* internal */ /* var */_otherDrops: Array<any>;

        /* internal */ /* var */_enterBtn: GButton;

        /* internal */ /* var */_delegateBtn: GButton;

        /* internal */ /* var */_warehouseBtn: GButton;

        /* internal */ /* var */_activeTip1: GTextFiled;

        /* internal */ /* var */_activeTip2: GTextFiled;

        /* internal */ /* var */_enterCall: Function;

        /* internal */ /* var */_delegateCall: Function;
    }
